package config_yaml

import (
	"os"
	"strings"
)

func GetCurrentPath() (string, error) {
	dir, err := os.Getwd()
	if err != nil {
		return "", err
	}
	return strings.Replace(dir, "\\", "/", -1), nil
}

func substr(s string, pos, length int) string {
	runes := []rune(s)
	l := pos + length
	if l > len(runes) {
		l = len(runes)
	}
	return string(runes[pos:l])
}

func GetParentDirectory() (string, error) {
	currentPath, err := GetCurrentPath()
	if err != nil{
		return "", err
	}
	return substr(currentPath, 0, strings.LastIndex(currentPath, "/")), nil
}


